function getcalenDar(year,month) {
   let firstDate =  new Date(year,month - 1,1)
   let lastDate =  new Date(year,month,0)
   let currentDays = lastDate.getDate()
   let sigle = `一\t二\t三\t四\t五\t六\t日\n`
   let week = firstDate.getDay()
   let lastWeek = lastDate.getDay()
   week = week==0 ? 6 : week - 1

   let pre_diff = 6 - week
   let last_diff = 7 - lastWeek

   
   if(week>0) {
      let lastDays = getMonthDay(year,month)
      console.log(`${lastDays}天`)
      for(let i=week-1;i>=0;i--){ 
        console.log(lastDays - i)
         sigle+=`${lastDays - i}\t`
      }
   } else {
        for(let i=0;i<week;i++){
            sigle+='\t'
        }
   }

  
   for(let i=1;i<=currentDays;i++){
      if((week+i)%7==0) sigle+=`${i}\n`
      else sigle+=`${i}\t`
   }
   if(last_diff) {
      for(let i=1;i<=last_diff;i++){
        sigle+=`${i}\t` 
      }
   }
   console.log(`----------${year}-${month}  共计${currentDays}天--第一天是周${week+1} 最后一天是周${lastWeek==0?'日':lastWeek}----------`)
                                                              
   console.log(`${sigle}`)
                                                                                                                                                      
   console.log(`------------------------------------------------------`)
}

function getMonthDay(year,month) {
   let lastDate =  new Date(year,month - 1,0)
   return lastDate.getDate()
}

getcalenDar(2024,0) 


